package ooday03;

public class RefArrayDemo {
    public static void main(String[] args) {

        Dog[]dogs= new Dog[3];//包含3个元素,每个元素都是Dog型,默认值为null
        dogs[0]=new Dog("小白",1,"红");
        dogs[1]=new Dog("小黑",1,"绿");
        dogs[2]=new Dog("小红",5,"白");
        for (int i=0;i<dogs.length;i++){
            System.out.println(dogs[i].name);
        }
        dogs[0].drink();
        System.out.println(dogs[0].name);

        Chick[]chicks=new Chick[2];
        chicks[0]=new Chick("小花",1,"白色");
        chicks[1]=new Chick("大花",2,"黑色");
        for (int i=0;i<chicks.length;i++){
            System.out.println(chicks[i].age);
        }

        Fish[]fish=new Fish[2];
        fish[0]=new Fish("小金",1,"金色");
        fish[1]=new Fish("小银",2,"银色");
        for (int i=0;i<chicks.length;i++){
            System.out.println(fish[i].color);
        }


    }
}
